Release 10.1A: OpenEdge Application Server:
Developing WebSpeed Applications
Customizing field object control handlers
Field object control handlers implement the conversion between HTML and the field object for each form element and custom tag that is mapped to your Web object. This mapping is defined by the combination of your HTML Web page and the
tagmap.datfile that you use for your application.The following shows the default
tagmap.datfile:
The
tagmap.datfile contains the HTML field definitions that specify the types of HTML form elements and custom tags used by all the Web objects in an application. WebSpeed provides a defaulttagmap.datfile that supports the common HTML form elements. You can add to or modify these field definitions as required. The default definitions include the HTML form elements that you can specify with the<INPUT>,<SELECT>, and<TEXTAREA>tags.Each HTML field definition takes up a line in
tagmap.datthat conforms to the following syntax:
tag-nameThe name that identifies the HTML tag. In an HTML form this is
input,select, ortextarea. For a custom tag, this is generally a name in the form of an HTML comment, such as!--MyTag. Using comments to define custom tags minimizes the chance of conflict with future versions of HTML. Note also that custom tags, unlike form elements, can appear anywhere in the HTML file.closing-tagThe closing tag name for HTML tags that require them, such as
/textarea.type-attributeThe
TYPEattribute for<INPUT>tags and any custom tags or future HTML tags that require aTYPEattribute such astextorhidden.field-object-typeThe type of SpeedScript field object to which this HTML or custom tag type is mapped. The supported SpeedScript field objects are
EDITOR,FILL-IN,RADIO-SET,TOGGLE-BOX, andSELECTION-LIST. By default, these correspond to the HTML form elements to which they most closely resemble in both form and function. SpeedScript supports each field object with a unique set of capabilities provided by SpeedScript attributes and methods. For more information on these capabilities, see the entry for each field object (referred to online as a widget) in the OpenEdge Development: Progress 4GL Reference .utility-pathnameThe pathname of a tagmap utility procedure file that contains the default
Note: Any line inweb.input andweb.outputcontrol handler procedures for this HTML or custom tag type. For the default field definitions, this path is relative to thePROPATHsettings. When you customize a field object control handler, you are replacing the control handler functionality provided by the corresponding tagmap utility. If you do not specify atagmaputility procedure, you must overrideweb.inputandweb.outputin the AppBuilder to do equivalent work.tagmap.datthat begins with a pound sign (#) is a comment.The Web page for the example
ncust-wo.w. illustrates how the field definitions correspond to the form elements and custom tags in an HTML file, as shown:
When the
TagExtractutility generates the offset file for this Web page using the defaulttagmap.datfile, it generates this offset file:
Note: You can interrupt offset generation at any point in an HTML file by inserting
<!--TagExtractSuspend-->at that point. You can then resume offset generation by inserting<!--TagExtractResume-->at a following point in the file.The offset file records each mappable tag (field) in order of its occurrence in the HTML file. For each tag (
Note: TagExtract understands UNIX pathnames infield[6]), it records theNAMEattribute value (Country), tagTYPE(INPUT), HTML visualization (radio), the corresponding SpeedScript field object type (radio-set) fromtagmap.dat, and four integers that record the starting line, starting character, ending line, and ending character of the tag specification in the HTML file (31,5,31,43). The only relevant information missing from this file is the location of the tagmap utility procedures. WebSpeed continues to get this information both during development and at run time from thetagmap.datfile (web/support/webradio.p).tagmap.dat(web/support/webradio.p) as well as MS-DOS pathnames (web\support\webradio.p). However, when you move your application to UNIX, you can only use UNIX pathnames. Therefore,tagmap.datuses UNIX pathnames by default.For many applications, the default tagmap utilities work well with the default tags. However, you can replace the default
web.inputorweb.outputcontrol handler for any tag using the control handler templates shown in the following:
Each template passes the same parameter for every tag. For
web.input, this is the current input value associated with the tag, expressed as a character string. This value is actually the output of theget-field()API function for the HTML field name.For web.output the parameter is the full HTML tag specification for the field from the source HTML file. If you want the output value, you must access the SpeedScript
SCREEN-VALUEattribute of the field object associated with the tag. You can reference the attribute using the full name of the field object. The field object name always has the same name as theNAMEattribute for the associated tag (replacing embedded spaces with underscores (_) and removing any illegal SpeedScript characters). Thus, for the Name field inncust-wo.htmyou can access the form buffer value usingName:SCREEN-VALUE.If the SpeedScript field object is a radio set,
web.outputexecutes once for each radio item. A second parameter (the item number) is also passed into the control handler.Placing your code inside the default
DOblock ensures that the object is properly referenced in its SpeedScript frame. Note also that, if the field object maps to a database field, the object name can be prefixed by the database and table names separated by periods (for example,sports2000.Customer.Name), depending on your AppBuilder settings.Finally, when creating custom tags, you can create your own tagmap utility procedures, such as
webinput.p. However, it is very common to rely on theweb.inputandweb.outputcontrol handlers in the Web object itself, instead of defining a separate utility procedure for the tag. This works when the custom tag maps to a standard SpeedScript field object likefill-in.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |